/**
 * Hook 用于函数监听
 * @method Hook
 * @date 2020-08-19
 * @param {Object} obj
 * @returns {Proxy} 返回代理的函数
 */
function Hook(obj) {
    window.hooks = window.hooks || [];
    obj.Func = [];
    let handle = {
        get(target, key) {
            return target[key];
        },
        set(target, key, value) {
            target[key] = value;
            return target;
        },
        apply: async function (target, thisArg, args) {
            for (let i = 0; i < target.Func.length; i++) {
                args = await target.Func[i](args);
            }
            return target(...args);
        },
    };

    let fake = new Proxy(obj, handle);
    window.hooks.push(fake);
    return fake;
}
